package com.work.washer.controller;

import com.work.washer.dto.SendReq;
import com.work.washer.model.Chat;
import com.work.washer.service.ChatService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author cys
 * @date 2024/4/26 18:42
 */
@Tag(name = "配送")
@RestController
@RequestMapping("/chat")
public class ChatController {

    @Autowired
    private ChatService chatService;


    /**
     * 添加
     *
     * @param send 发送
     * @return boolean
     */
    @Operation(summary = "新增对话")
    @PostMapping("/say")
    public void say(@RequestBody SendReq req) {
        chatService.say(req);
    }

    @Operation(summary = "列表")
    @GetMapping("/list")
    public List<Chat> list() {
        return chatService.lambdaQuery().orderByAsc(Chat::getId).list();
    }


}
